<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>66vue中绑定的样式</title>
  <script src="./vue.js"></script>
  <style>
    .activated {
      color: red;
    }
  </style>
</head>
<body>
  <div id="root">
    <!--class的对象绑定-->
    <!-- <div @click="handleClick"
         :class="{activated: isActivated}"> 
      hello world
    </div>  -->

    <!-- class使用数组绑定 -->
    <div @click="handleClick"
         :class="[activated]"> 
      hello world
    </div>
  </div>
  <script>
    var vm = new Vue({
      el: '#root',
      data: {
        // class使用对象绑定
        // isActivated: false

        // class使用数组绑定
        activated: "",
      },
      methods: {
        handleClick: function() {
        // class使用对象绑定
          // this.isActivated = !this.isActivated ;

        // class使用数组绑定
          // if(this.activated === "activated") {
          //   this.activated = "";
          // } else {
          //   this.activated = "activated";
          // }
          this.activated = this.activated === "activated" ? this.activated = "" : this.activated = "activated";
        }
      }
     
    })
  </script>
</body>
</html>